const isProduction = process.env.NODE_ENV=== 'production'
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
	configureWebpack:config =>{
		if(isProduction){
			config.externals = {
				'vue':'Vue',
				'vue-router':'VueRouter',
				'axios':'axios',
			}
			config.plugins.push(new HtmlWebpackPlugin({
				template:'./index.template.html',
				title:'聚超值'
			}))
		}
	},
    runtimeCompiler: true,
    // publicPath: '.', // 设置打包文件相对路径
    devServer: {
      // open: process.platform === 'darwin',
      // host: 'localhost',
      port: 8080,
      // open: true, //配置自动启动浏览器
      //http://localhost:3000/api/home?sectionId="99"
      //http://localhost:8080/api
      proxy: {
        '/api': {
          target: 'http://localhost:3000', //对应自己的接口
          changeOrigin: true,
          ws: true,
          pathRewrite: {
            '^/api': ''
          }
        }
      }
     },
  }